/*
 * CdnArea.h
 *
 *  Created on: Apr 22, 2013
 *      Author: root
 */

#ifndef CDNAREA_H_
#define CDNAREA_H_

#include "smart_lock.h"

/**
 * area Node Type
 */
enum AreaType {AREA, ROOM, SVRNODE};

/*
 * cdn area base class
 */
class CdnArea {
public:
	CdnArea();
	CdnArea(AreaType _type);
	virtual ~CdnArea();
	virtual int ApendChildToLast(CdnArea * pNode);
	virtual int InitNode(int _id,const char * pname);

	int      GetId();
	AreaType GetType();
	void     SetName(const char * pname);
	const char * GetName();

	void lock();
	void unlock();

public:
	CdnArea * parent;
	CdnArea * firstChild;
	CdnArea * lastChild;
	CdnArea * nextSibling;
	CdnArea * prevSibling;
	int 	  nodeIndex;
	int 	  childCount;
	int       treelevel;

protected:
	int  	    id;
	char 	    name[GUID_LEN];
	smart_lock  olock;
	AreaType    type;

	void initArea(AreaType _type);
};

#endif /* CDNAREA_H_ */
